/*
 * @Description: 举报
 * @Author: iamsmiling
 * @Date: 2021-06-09 21:46:53
 * @LastEditTime: 2021-06-15 17:45:17
 */
import 'package:credit_business_circle/R/R.dart';
import 'package:credit_business_circle/pages/report/report_controller.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

class ReportPage extends StatelessWidget {
  const ReportPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: R.color.ffffffff,
      appBar: AppBar(
        title: Text("我要举报"),
        elevation: .5,
      ),
      body: GetBuilder<ReportController>(
        builder: (_) {
          return SingleChildScrollView(
            child: Container(
              padding: EdgeInsets.symmetric(horizontal: R.dimen.dp16),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Container(
                    margin: EdgeInsets.symmetric(vertical: R.dimen.dp27),
                    child: Text(
                      "举报原因：",
                      style: TextStyle(
                          fontSize: R.dimen.sp16,
                          color: R.color.ff333333,
                          fontWeight: FontWeight.w600),
                    ),
                  ),
                  DefaultTextStyle(
                      style: TextStyle(
                        fontSize: R.dimen.sp15,
                        color: R.color.ff333333,
                      ),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          for (ReportReason item in ReportReason.values)
                            Row(
                              children: [
                                Checkbox(
                                  value: _.reason == item,
                                  materialTapTargetSize:
                                      MaterialTapTargetSize.shrinkWrap,
                                  tristate: true,
                                  side: BorderSide(
                                    color: R.color.ffcccccc,
                                  ),
                                  shape: RoundedRectangleBorder(
                                      borderRadius:
                                          BorderRadius.circular(R.dimen.sp9)),
                                  onChanged: (bool? flag) {
                                    _.selectReason(flag, item);
                                  },
                                  activeColor: R.color.ff00c28a,
                                ),
                                Container(
                                  child: Text(item.name),
                                )
                              ],
                            )
                        ],
                      )),
                  Container(
                    margin: EdgeInsets.only(
                        top: R.dimen.dp20, bottom: R.dimen.dp20),
                    child: Text(
                      "举报原因：",
                      style: TextStyle(
                          fontSize: R.dimen.sp16,
                          color: R.color.ff333333,
                          fontWeight: FontWeight.w600),
                    ),
                  ),
                  Container(
                    padding: EdgeInsets.only(
                        top: R.dimen.dp10,
                        bottom: R.dimen.dp10,
                        left: R.dimen.dp16,
                        right: R.dimen.dp16),
                    decoration: BoxDecoration(
                        borderRadius: BorderRadius.circular(R.dimen.sp5),
                        border: Border.all(color: R.color.ffcccccc)),
                    child: TextFormField(
                      buildCounter: (BuildContext context,
                          {required int currentLength,
                          required int? maxLength,
                          required bool isFocused}) {
                        return Text(
                          "$currentLength/$maxLength",
                          style: TextStyle(
                              fontSize: R.dimen.sp13, color: R.color.ff999999),
                        );
                      },
                      maxLength: 20,
                      maxLines: 3,
                      decoration: InputDecoration(
                        hintText: "请进一步说明您的举报理由...",
                        hintStyle: TextStyle(
                          fontSize: R.dimen.sp14,
                          color: R.color.ff888888,
                        ),
                      ),
                    ),
                  ),
                  Container(
                    margin: EdgeInsets.only(
                        top: R.dimen.dp32, bottom: R.dimen.dp24),
                    child: Text(
                      "附加证据图片：",
                      style: TextStyle(
                          fontSize: R.dimen.sp16,
                          color: R.color.ff333333,
                          fontWeight: FontWeight.w600),
                    ),
                  ),
                  Container(
                      child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Image.asset(
                        R.image.uploadImage,
                        width: (R.dimen.width -
                                R.dimen.dp15 * 2 -
                                R.dimen.dp22 * 2) /
                            3.001,
                        fit: BoxFit.fitWidth,
                      ),
                      Image.asset(
                        R.image.uploadImage,
                        width: (R.dimen.width -
                                R.dimen.dp15 * 2 -
                                R.dimen.dp22 * 2) /
                            3.001,
                        fit: BoxFit.fitWidth,
                      ),
                      Image.asset(
                        R.image.uploadImage,
                        width: (R.dimen.width -
                                R.dimen.dp15 * 2 -
                                R.dimen.dp22 * 2) /
                            3.001,
                        fit: BoxFit.fitWidth,
                      ),
                    ],
                  ))
                ],
              ),
            ),
          );
        },
      ),
      bottomNavigationBar: Container(
        margin: EdgeInsets.only(bottom: Get.mediaQuery.padding.bottom),
        padding: EdgeInsets.symmetric(horizontal: R.dimen.dp16),
        child: ElevatedButton(
            onPressed: () {},
            child: Text(
              "提交",
              style: TextStyle(fontSize: R.dimen.sp16),
            )),
      ),
    );
  }
}
